home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / batch.zip / REPLY.DOC < prev    next >
Text File  |  1987-12-15  |  15KB  |  396 lines

  1.  
  2.  
  3.  
  4.                                 REPLY.COM
  5.  
  6.  
  7.  
  8.                       Created By:  Charles Thurston
  9.  
  10.  
  11.                            Of:  Sunnyvale, CA
  12.  
  13.  
  14.                               October 1987
  15.  
  16.  
  17.      This file contains the following:
  18.  
  19.           1)   A short description of the REPLY program.
  20.           2)   An example of its use in a .BAT file.
  21.           3)   A copy of the assembly program (REPLY.ASM).
  22.  
  23. ******************************************************************************
  24.      This program is FREE, however, if you find it useful, please make a
  25. contribution to any charity you wish, since that's where good money should go.
  26. ******************************************************************************
  27.  
  28. REPLY Description:
  29.  
  30.      I have seen several programs out there which let the user make decisions
  31. inside a .BAT process, and allow the user to change course in that process
  32. based on the outcome.  All of these programs have their good and bad points. 
  33. This program, REPLY.COM, combines what I consider to be all of their good
  34. points into one routine.
  35.  
  36.      REPLY has the following features:
  37.  
  38.           a)   REPLY's response parameters, those of which the user can choose
  39.                from, may be entered in any order.
  40.  
  41.           b)   If no valid response is received after 10 seconds, REPLY will
  42.                perform a DEFAULT response, which can also be used as a
  43.                parameter for the .BAT file to react upon.
  44.  
  45.           c)   While in the 10 second period, a response is entered which is
  46.                not valid, REPLY will ignore it and continue to wait for a
  47.                correct response of the end of the 10 second period.
  48.  
  49.           c)   All comments, to be used to prompt the user of his/her chooses,
  50.                are performed using "echo" statements prior to performing REPLY.
  51.  
  52.                Therefore, the decision prompt is not limited to one line.
  53.  
  54.           d)   REPLY accepts response parameters of 1-9 and a-z.
  55.  
  56.                1)   Allowing for a total of 35 possible chooses.
  57.  
  58.                2)   All letters, a-z, are converted to upper case, so "a" and
  59.                     "A" are considered the same response.  This allows the user
  60.                     the freedom of having the same response regardless of the
  61.                     "Shift" or "Caps Lock" condition of their machine at the
  62.                     time of their response.
  63.  
  64.  
  65.                                         1
  66.  
  67.           e)   REPLY checks the validity of all commend line parameters.  If
  68.                there are any invalid, missing, or duplicate response
  69.                parameters, REPLY will output an error message.
  70.  
  71.      REPLY parameters can be used in several ways. The following statements are
  72. examples of REPLY commands:
  73.  
  74.           REPLY 123456789abcdefghijklmnopqrstuvwxyz
  75. or
  76.           REPLY 123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ
  77. or 
  78.           REPLY y
  79. or even something weird like this
  80.           REPLY 1a3E4g2W7z9X
  81.  
  82.      In a batch file after running REPLY, the "if errorlevel" command is used
  83. to check which response parameter was chosen.  The "if errorlevel" number to be
  84. tested for each response parameter is assigned soully by the order in which the
  85. parameters appear in the REPLY command line.  For example:
  86.  
  87.                          REPLY 123456789abcdefghijklmnopqrstuvwxyz
  88.                                |              |                  |
  89.                                |              |                  |
  90.      "if errorlevel" code:    "1"           "16"               "35"
  91.  
  92.      The "if errorlevel" code for the 10 second timeout is "0".
  93.  
  94. Note:     When using the "if errorlevel" batch command, the number tests must
  95.           always be checked in descending order, since the "if errorlevel" is
  96.           "True" if the test is "Greater than or equal".
  97. ******************************************************************************
  98.  
  99. Example Of Using REPLY In A .BAT File
  100.  
  101.      An example of using REPLY in a .BAT file follows:
  102.  
  103. AUTOEXEC.BAT
  104.  
  105. echo off
  106. echo ************************************************************
  107. echo * ABORT TO DOS?            (10 seconds to decide)          *
  108. echo *                                                          *
  109. echo * Chooses:  Y(yes) / N(no)  or TIMEOUT @ End Of 10 Seconds *
  110. echo ************************************************************
  111. reply yn
  112. if errorlevel 2 goto CONTINUE
  113. if errorlevel 1 goto EXIT
  114. rem  **** continue with default option ****
  115. ....(1).......
  116. ............
  117. ..........
  118. ........
  119. goto EXIT
  120. :CONTINUE
  121. ....(2).......
  122. ............
  123. ..........
  124. ........
  125. :EXIT
  126.  
  127.  
  128.  
  129.  
  130.  
  131.                                         2
  132.  
  133. When this batch file is performed, the following will appear on the screen:
  134.  
  135. ************************************************************
  136. * ABORT TO DOS?            (10 seconds to decide)          *
  137. *                                                          *
  138. * Chooses:  Y(yes) / N(no)  or TIMEOUT @ End Of 10 Seconds *
  139. ************************************************************
  140. RESPONSE: . . . . .
  141.  
  142. at which time a response may be entered.  Another "." will appear each second
  143. until a correct response of either "y" of "n" is entered, or the 10 seconds
  144. elapses.  If "n" is entered, an "N" will appear on the "RESPONSE" line, the
  145. batch file will perform process (2) and exit.  If "y" is entered, a "Y" will
  146. appear and the batch file will exit.  If the 10 second timeout occurs,
  147. "DEFAULT" will appear, process (1) will be performed and exit.
  148. ******************************************************************************
  149.  
  150.  
  151. REPLY.ASM Listing
  152.  
  153.      For those of you who may wish to modify, or use portions of this routine
  154. for other purposes, The following is the assembly program from which REPLY was
  155. produced, and you're welcome to it.
  156.  
  157. PAGE ,132                                  ;SET FOR WIDE LISTING
  158. ; REPLY.ASM
  159. ;--------------------------------------------------------------------
  160. CODE_SEG      SEGMENT
  161.               ASSUME CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG,ES:CODE_SEG
  162. ;             ORG 100H                     ;THIS COMMAND WAS NOT NEEDED
  163. ;====================================================================
  164. ; BEGINNING OF PROGRAM
  165. ;
  166.               CALL    INPUT                ;GO TO INPUT CHECKING
  167.               CMP     AL,86H               ;WAS THERE AN ERROR(86H)
  168.               JZ      EXIT                 ;IF YES, EXIT
  169.               CALL    WAIT                 ;GO TO WAITING ROUTINE
  170. EXIT:         MOV     AH,4CH               ;
  171.               INT     21H                  ;EXIT WITH CODE IN AL
  172. ;====================================================================
  173. ; DATA AREA ------ ESTABLISH TABLES AND SYMBOLS
  174. ;
  175. TABLE  DB  31H DUP(0),'123456789',7H DUP(0),'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  176. TABLE2 DB  6H DUP(0),'ABCDEFGHIJKLMNOPQRSTUVWXYZ',85H DUP(0)
  177. DUPLIST    DB     80H DUP(0)
  178. RESPONSES  DB     24H DUP(0)
  179. NONE       DB    'Missing Reply Parameter.',0DH,0AH,24H
  180. WRONG      DB    'Invalid Reply Parameter.',0DH,0AH,24H
  181. DOUBLE     DB    'Duplicate Reply Parameter.',0DH,0AH,24H
  182. ASKTHIS    DB    'RESPONSE:$'
  183. TIMETICK   DB    ' .$'
  184. TIMEOUT    DB    ' DEFAULT',0DH,0AH,24H
  185. FEED       DB     0DH,0AH,24H
  186. ;====================================================================
  187. ; CHARACTER INPUT AND CHECKING SUBROUTINE
  188. ;
  189. INPUT:        CLD                          ;CLEAR DF
  190.               XOR     CX,CX                ;  "   CX
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.                                         3
  198.  
  199.               MOV     DI,0080H             ;SET DI TO INPUT STRING
  200.               MOV     CL,[DI]              ;PUT COUNT INTO CX
  201.               JCXZ    MISSING              ;IF CX=0 PRINT MISSING & END
  202.               DEC     CX                   ;SKIP LEADING SPACE
  203.               MOV     BP,CX                ;PUT CX IN BP FOR LATER
  204.               XOR     AX,AX                ;CLEAR AX
  205.               MOV     SI,0082H             ;SI POINTS TO INPUT STRING
  206.               LEA     DI,RESPONSES+0100H   ;DI   "    "  RESPONSES
  207.               LEA     BX,TABLE+0100H       ;BX   "    "  TABLE
  208. TRANSLATE:    LODSB                        ;PUT [SI] INTO AL, INC SI
  209.               XLAT                         ;[BX+AL]=>AL
  210.               CMP     AL,00H               ;CHECK IF VALID CHARACTER
  211.               JZ      INVALID